<?
class FeiticoAcidArrow extends Feitico {
	
	function __construct () {

		parent::__construct('flecha ácida');
		
		//type: abjuration, conjuration
		$this->school = 'conjuration';
		$this->subschool = 'creation';
		
		// descriptor: 
		$this->classes_level = new ListaDeElementos();
		$this->classes_level->adiciona(array('sor', 2));
		$this->classes_level->adiciona(array('wiz', 2));
		
		// types: verbal (v), somatic (s), material (m), focus (f), divine focus (df), XP Cost (xp) 
		$this->components = new ListaDeElementos();
		$this->components->adiciona('v');
		$this->components->adiciona('s');
		$this->components->adiciona('m');
		$this->components->adiciona('f');
		
		// types: standart action, free action, full round
		$this->casting_time		= 'standart';
		
		// types: personal, touch, close, medium, long, unlimited, nºfeets
		$this->range			= 'long';
		
		//types: creatures, objects, area, line of effect (effects)
		$this->target			= 'creature';
		
		// types: intantaneous, timed duraction, permanent, concentration, (Subjects, Effects, and Areas), (Touch Spells and Holding the Charge), Discharge, Dismissible;
		$this->duration			= array('timed', 60);
		$this->repeat			= 30;
		
		// types: negates, partial, half, none, disbelief, object, harmless, Saving Throw Difficulty Class, Succeeding on a Saving Throw, Automatic Failures and Successes, 
		//Voluntarily Giving up a Saving Throw, Items Surviving after a Saving Throw
		// Items Affected by Magical Attacks: Shield, Armor, Magic helmet, hat, or headband, Item in hand (including weapon, wand), Magic cloak, etc...
		$this->saving_throw		= array('Fortitude', 0);
		
		//types: true, false
		$this->spell_resistance	= false;
		
		// types: true, false
		$this->allow_permanent	= false;
	}
	
	public function activar(&$target, $attack_roll) {
		$dado20 = new Dado(20);
		$dado4 = new Dado(4);
		$dano = $dado4->lancar(2,0);
		
		// GET DEFENDER MODIFIERS
		$def_size_mod = floor((6 - $target->getValue('size')) * 1.2);
		$def_str_mod = $target->getMod($target->getValue('str'));
		$def_dex_mod = $target->getMod($target->getValue('dex'));
		$def_con_mod = $target->getMod($target->getValue('con'));
		$def_int_mod = $target->getMod($target->getValue('int'));
		$def_wis_mod = $target->getMod($target->getValue('wis'));
		$def_car_mod = $target->getMod($target->getValue('car'));
		
		if ($this->saving_throw[0] != 'none') {
			$def_saving_throw = $dado20->lancar(1,0) + $target->getValue('save'. $this->saving_throw[0]);
			switch ($this->saving_throw[0]) {
				case 'Fortitude': $def_saving_throw += $def_con_mod; break;
				case 'Reflex': $def_saving_throw += $def_dex_mod; break;
				case 'Will': $def_saving_throw += $def_wis_mod; break;
				default: ;
			}
		}
		
		$dc = $attack_roll;
		echo "dc=".$dc.", def_st=".$def_saving_throw;
		if ($dc <= $def_saving_throw) {
			$target->setValue('hp', $target->getValue('hp') - $dano);
			if ($this->duration[0] != 'instantaneous') $target->adicionaFeitico($this);
			return true;
		} else return false;
	}
	
	public function desactivar($target) {
		$target->removeFeitico($this);
	}
	
	public function getDuration() {
		return $this->duration;
	}
}
?>